from utils.ssh import secure_crt
import logging
logging.basicConfig(level=logging.INFO)

crt = secure_crt('192.168.89.128', 'root', 'yuchen123456')
flag, res = crt.exec_cmd('source /etc/profile && java -version')
if not flag:
#使用自己的路径
    crt.copy_file(r'D:\CodePartice\AutoPython\File\jdk-8u261-linux-x64.tar.gz',
                  r'/opt/jdk-8u261-linux-x64.tar.gz')
    crt.yum('cd /opt && tar -zxvf jdk-8u261-linux-x64.tar.gz')
#crt.yum('cd /opt &&  wegt jdk地址')
    crt.exec_cmd("echo 'export JAVA_HOME=/opt/jdk1.8.0_261' >> /etc/profile")
    crt.exec_cmd("echo 'export CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib' >> /etc/profile")
    crt.exec_cmd("echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile")
#让文件生效
    crt.exec_cmd("source /etc/profile")
crt.yum('java -version')



